#include "config.h"
#include "printk.h"
#include "linux/sched.h"
#include "linux/list.h"

typedef struct 
{
	unsigned char sp[TASK_STACK_SIZE];
}stack_t;


struct task_struct 	task_pcb[MAX_TASK_NUM];
stack_t	task_sp[MAX_TASK_NUM];
struct task_struct *alloc_pcb(void)
{
	static unsigned int cur_pcb = 0;
	
	if (cur_pcb < MAX_TASK_NUM)
	{
		INIT_LIST_HEAD(&task_pcb[cur_pcb].wq.task_list);
		return &task_pcb[cur_pcb++];
	}

	return 0;
}

void *alloc_stack(void)
{

	static unsigned int cur_sp = 0;
	if (cur_sp < MAX_TASK_NUM)
		return (void *)(task_sp[cur_sp++].sp);

	return 0;
}
